/*************************************************************************
 *                                                                       *
 * This file is part of the FreeMAPs distribution.  For full copyright   *
 * information, see COPYRIGHT and COPYING.LESSER.                        *
 *                                                                       *
 * Author:        sqbang                                                 *
 * Email:         sqbang@ustc.edu                                        *
 * Date:          2012.01.12                                             *
 *                                                                       *
 *************************************************************************/

#ifndef FreeMAPs_include_COMMON_syst_SystemStrategy_h
#define FreeMAPs_include_COMMON_syst_SystemStrategy_h

#include "FreeMAPsConfig.h"

//COMMON headers
#include "COMMON/base/StateIndicator.h"
#include "COMMON/enum/SystemType.h"

namespace FreeMAPs
{

//forward declarations
class PDEEquationEnsembleStrategy;
class TimePatch;

/**
 * the system is used to form the equation of linear algebra equation Ax=b
 * or nonlinear equation f(x)=0
 * after the equation is builded, using the solver to solve it.
 * it different to solver is:
 * system build the equation and solver solve it.
 * @see SolverStrategy
 */
class SystemStrategy : public StateIndicator
{
public:

    SystemStrategy (
        const std::string& parent_name,
        const std::string& object_name,
        PDEEquationEnsembleStrategy& equation_ensemble);

    virtual
    ~SystemStrategy();

public:

    inline const PDEEquationEnsembleStrategy&
    get_equation_ensemble() const;

    inline PDEEquationEnsembleStrategy&
    get_equation_ensemble();


public:
    // system type
    const std::string
    get_system_type() const;

    void set_system_type(
            const std::string& system_type);

    // solve method
    const std::string
    get_solver_method() const;

    void set_solver_method(
            const std::string& solver_method);

public:
    void
    clear();

    void
    get_from_input (
        const InputDatabase* db);

    friend std::ostream&
    operator << (
        std::ostream& os,
        const SystemStrategy& rhs);

protected:

    PDEEquationEnsembleStrategy& d_equation_ensemble;

    /*
     * each system will have a identity id.
     * the id is VERY important for a system that use libMesh::DofMap
     * to decide it's dof.
     */
    int d_id;

private:
    // type
    std::string d_system_type;

    // solver type
    std::string d_solver_method;

private:

    DISALLOW_COPY_AND_ASSIGN (SystemStrategy);
};

}

#include "COMMON/syst/SystemStrategy.inl"

#endif
